Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jun 25, 2025

This PR modifies the behaviour of this compile-time macro diagnostic:

🛑 "Attribute 'Test' specifies display name 'foo' for function with implicit display name 'bar'

If bar (in the above context) is not considered a raw identifier by the language, we emit a warning instead of an error. This will allow us to adjust display-name-from-backticked-name inference (see #1174) without introducing a source-breaking change for a declaration such as:

@Test("subscript([K]) operator")
func `subscript`()

(The above is a real-world test function in our own package that would be impacted.)

Note that we don't actually have a code path that triggers this warning yet. #1174, if approved and merged, would introduce such a code path. Here's an example of what that would look like:

Screenshot showing the warning diagnostic presented for func subscript()

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

…ames.

This PR modifies the behaviour of this compile-time macro diagnostic:

> 🛑 "Attribute 'Test' specifies display name 'foo' for function with implicit
> display name 'bar'

If `bar` (in the above context) is _not_ considered a raw identifier by the
language, we emit a warning instead of an error. This will allow us to adjust
display-name-from-backticked-name inference (see #1174) without introducing a
source-breaking change for a declaration such as:

```swift
@test("subscript([K]) operator")
func `subscript`()
```

(The above is a real-world test function in our own package that would be
impacted.)

Note that we don't actually have a code path that triggers this warning yet.
 #1174, if approved and merged, would introduce such a code path.
@grynspan grynspan added this to the Swift 6.x milestone Jun 25, 2025
@grynspan grynspan self-assigned this Jun 25, 2025
@grynspan grynspan added enhancement New feature or request macros 🔭 Related to Swift macros such as @Test or #expect raw-identifiers 🧅 Support for raw identifiers labels Jun 25, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan changed the title Lower the "ambiguous display name" diagnostic to a warning for some n… Lower the "ambiguous display name" diagnostic to a warning for some names. Jun 25, 2025
@grynspan grynspan merged commit 3ee5ec0 into main Jun 25, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/ambiguous-display-name-as-warning-sometimes branch June 25, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request macros 🔭 Related to Swift macros such as @Test or #expect raw-identifiers 🧅 Support for raw identifiers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants